package com.mrdeer.uaa.api.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mrdeer.common.util.DateUtil;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author ：xie jianchu
 * @date ：Created in 2020/9/4 0004 9:36
 */
@Data
@TableName("oauth_client_details")
public class OAuthClientDetails implements Serializable {
    private static final long serialVersionUID = 3127610769307808559L;

    private LocalDateTime createTime = DateUtil.now();

    private boolean archived = false;

    /**
     * 客户端标识
     */
    @TableId(value = "client_id", type = IdType.ID_WORKER)
    private String clientId;

    /**
     * 接入资源列表
     */
    private String resourceIds;

    /**
     * 客户端密钥
     */
    private String clientSecret;

    private String scope;

    /**
     * grant types include
     * "authorization_code","password","assertion","refresh_token"
     * Default value is "authorization_code,refresh_token"
     */
    private String authorizedGrantTypes = "authorization_code,refresh_token";

    private String webServerRedirectUri;

    private String authorities;

    private Integer accessTokenValidity;

    private Integer refreshTokenValidity;

    private String additionalInformation;

    private boolean trusted = false;

    private String autoApprove;

    public OAuthClientDetails() {
    }

    public String autoApprove() {
        return autoApprove;
    }

    public OAuthClientDetails autoApprove(String autoApprove) {
        this.autoApprove = autoApprove;
        return this;
    }

    public boolean trusted() {
        return trusted;
    }

    public OAuthClientDetails createTime(LocalDateTime createTime) {
        this.createTime = createTime;
        return this;
    }

    public boolean archived() {
        return archived;
    }

    public String clientId() {
        return clientId;
    }

    public String resourceIds() {
        return resourceIds;
    }

    public String clientSecret() {
        return clientSecret;
    }

    public String scope() {
        return scope;
    }

    public String authorizedGrantedTypes() {
        return authorizedGrantTypes;
    }

    public String webServerRedirectUri() {
        return webServerRedirectUri;
    }

    public String authorities() {
        return authorities;
    }

    public Integer accessTokenValidity() {
        return refreshTokenValidity;
    }

    public Integer refreshTokenValidity() {
        return refreshTokenValidity;
    }

    public String additionalInformation() {
        return additionalInformation;
    }

    public OAuthClientDetails clientId(String clientId) {
        this.clientId = clientId;
        return this;
    }

    public OAuthClientDetails clientSecret(String clientSecret) {
        this.clientSecret = clientSecret;
        return this;
    }

    public OAuthClientDetails resourceIds(String resourceIds) {
        this.resourceIds = resourceIds;
        return this;
    }

    public OAuthClientDetails authorizedGrantTypes(String authorizedGrantTypes) {
        this.authorizedGrantTypes = authorizedGrantTypes;
        return this;
    }

    public OAuthClientDetails scope(String scope) {
        this.scope = scope;
        return this;
    }

    public OAuthClientDetails webServerRedirectUri(String webServerRedirectUri) {
        this.webServerRedirectUri = webServerRedirectUri;
        return this;
    }

    public OAuthClientDetails authorities(String authorities) {
        this.authorities = authorities;
        return this;
    }

    public OAuthClientDetails accessTokenValidity(Integer accessTokenValidity) {
        this.accessTokenValidity = accessTokenValidity;
        return this;
    }

    public OAuthClientDetails refreshTokenValidity(Integer refreshTokenValidity) {
        this.refreshTokenValidity = refreshTokenValidity;
        return this;
    }

    public OAuthClientDetails trusted(boolean trusted) {
        this.trusted = trusted;
        return this;
    }

    public OAuthClientDetails additionalInformation(String additionalInformation) {
        this.additionalInformation = additionalInformation;
        return this;
    }

    public OAuthClientDetails archived(boolean archived) {
        this.archived = archived;
        return this;
    }

    @Override
    public String toString() {
        return "OAuthClientDetails{" +
                "createTime=" + createTime +
                ", archived=" + archived +
                ", clientId='" + clientId + '\'' +
                ", resourceIds='" + resourceIds + '\'' +
                ", clientSecret='" + clientSecret + '\'' +
                ", scope='" + scope + '\'' +
                ", authorizedGrantTypes='" + authorizedGrantTypes + '\'' +
                ", webServerRedirectUri='" + webServerRedirectUri + '\'' +
                ", authorities='" + authorities + '\'' +
                ", accessTokenValidity=" + accessTokenValidity +
                ", refreshTokenValidity=" + refreshTokenValidity +
                ", additionalInformation='" + additionalInformation + '\'' +
                ", trusted=" + trusted +
                ", autoApprove='" + autoApprove + '\'' +
                '}';
    }
}
